<template>
    <div>
        <div class="col-md-12" style="border-top: 1px solid #ccc;border-bottom: 1px solid #ccc;">
              <el-row>
                <el-col :span="16" style="padding-left:20px">
                    <el-tooltip
                            class="item"
                            effect="dark"
                            content="选择要显示的列"
                            placement="top"
                    >
                        <el-popover placement="bottom" width="300" trigger="click">
                            <el-col :span="12">
                                <el-checkbox v-model="showCustomerCode" @change="showHide('showCustomerCode')">客户代码
                                </el-checkbox>
                            </el-col>
                            <el-col :span="12">
                                <el-checkbox
                                        v-model="showCustomerStatus"
                                        @change="showHide('showCustomerStatus')"
                                >客户状态
                                </el-checkbox>
                            </el-col>
                            <el-col :span="12">
                                <el-checkbox v-model="showCustomerCate" @change="showHide('showCustomerCate')">客户类别
                                </el-checkbox>
                            </el-col>
                            <el-col :span="12">
                                <el-checkbox v-model="showCreditRank" @change="showHide('showCreditRank')">客户信用等级
                                </el-checkbox>
                            </el-col>
                            <el-col :span="12">
                                <el-checkbox v-model="showCreditLine" @change="showHide('showCreditLine')">授信额度
                                </el-checkbox>
                            </el-col>
                            <el-col :span="12">
                                <el-checkbox v-model="showCapital" @change="showHide('showCapital')">注册资金</el-checkbox>
                            </el-col>
                            <el-col :span="12">
                                <el-checkbox v-model="showAnnualSales" @change="showHide('showAnnualSales')">年销售额
                                </el-checkbox>
                            </el-col>
                            <el-col :span="12">
                                <el-checkbox v-model="showBank" @change="showHide('showBank')">对公银行账号</el-checkbox>
                            </el-col>
                            <el-col :span="12">
                                <el-checkbox
                                        v-model="showCertificateNo"
                                        @change="showHide('showCertificateNo')"
                                >开户银行
                                </el-checkbox>
                            </el-col>
                            <el-col :span="12">
                                <el-checkbox v-model="showAddress" @change="showHide('showAddress')">税务登记证号
                                </el-checkbox>
                            </el-col>
                            <el-col :span="12">
                                <el-checkbox v-model="showArea" @change="showHide('showArea')">地址</el-checkbox>
                            </el-col>
                            <el-col :span="12">
                                <el-checkbox v-model="showBrand" @change="showHide('showBrand')">经营面积</el-checkbox>
                            </el-col>
                            <el-col :span="12">
                                <el-checkbox
                                        v-model="showBankAccount"
                                        @change="showHide('showBankAccount')"
                                >模拟，对应列表的列项
                                </el-checkbox>
                            </el-col>
                            <el-button size="small" slot="reference" type="plain" class="setting">
                                <div style="display: flex;flex-direction: column;">
                                    <i class="el-icon-setting"></i>
                                    <span style="margin-top: 3px">显示设置</span>
                                </div>
                            </el-button>
                        </el-popover>
                    </el-tooltip>

                    <el-input
                            placeholder
                            v-model="inputSearch"
                            class="input-with-select input-search"
                            style="margin-left:10px;width:450px;height:47px;top:9px"
                            speech
                            x-webkit-speech
                            size="large"
                    >
                        <el-select v-model="selectsearch" slot="prepend" placeholder="请选择">
                            <el-option label="客户名称" value="1"></el-option>
                            <el-option label="业务联系人" value="2"></el-option>
                            <el-option label="业务电话" value="3"></el-option>
                            <el-option label="合作状态" value="4"></el-option>
                            <el-option label="序号id" value="5"></el-option>
                            <el-option label="客户代码" value="6"></el-option>
                        </el-select>
                        <i slot="prefix" class="iconfont iconpaizhao1"></i>

                        <el-button slot="append" icon="el-icon-search" style="height:47px;">查询</el-button>
                    </el-input>
                </el-col>

                <el-col :span="8" style="padding-right:10px">

                <el-button @click="handleDelCustomer(1)" size="small"
                           style="margin-top: 10px;margin-bottom: 10px;margin-left: 10px;float: right" type="plain" class="setting">
                    <div style="display: flex;flex-direction: column;"><i class="el-icon-setting"></i><span
                            style="margin-top: 3px">删除</span></div>
                </el-button>

                <el-button @click="handleImport(2)" size="small"
                           style="margin-top: 10px;margin-bottom: 10px;float: right" type="plain" class="setting">
                    <div style="display: flex;flex-direction: column;"><i class="el-icon-setting"></i><span
                            style="margin-top: 3px">导出</span></div>
                </el-button>

                <el-button @click="handleImport(1)" size="small"
                           style="margin-top: 10px;margin-bottom: 10px;float: right" type="plain" class="setting">
                    <div style="display: flex;flex-direction: column;"><i class="el-icon-setting"></i><span
                            style="margin-top: 3px">导入</span></div>
                </el-button>

                <el-button @click="handleButtons(2)" size="small"
                           style="margin-top: 10px;margin-bottom: 10px;float: right" type="plain" class="setting">
                    <div style="display: flex;flex-direction: column;"><i class="el-icon-setting"></i><span
                            style="margin-top: 3px">发微信</span></div>
                </el-button>
                <el-button @click="handleButtons(3)" size="small"
                           style="margin-top: 10px;margin-bottom: 10px;float: right" type="plain" class="setting">
                    <div style="display: flex;flex-direction: column;"><i class="el-icon-setting"></i><span
                            style="margin-top: 3px">发邮件</span></div>
                </el-button>
                <el-button @click="handleButtons(1)" size="small"
                           style="margin-top: 10px;margin-bottom: 10px;float: right" type="plain" class="setting">
                    <div style="display: flex;flex-direction: column;"><i class="el-icon-setting"></i><span
                            style="margin-top: 3px">发短信</span></div>
                </el-button>
                </el-col>
          </el-row>
        </div>
        
        <el-table
                ref="multipleTable"
                :data="tableData"
                border
                stripe
                height="600"
                row-class-name="tableRow"
                header-row-class-name="tableHeader"
                @row-dblclick="handleButtons(4)"
                style="width: 100%;border-top:1px solid #c5c5c5;">
            <el-table-column
                    type="selection"
                    width="55">
            </el-table-column>
            <el-table-column
                    prop="id"
                    sortable
                    label="序号"
                    width="50">
            </el-table-column>
            <el-table-column
                    prop="date"
                    sortable
                    label="跟时时间"
                    width="150">
            </el-table-column>
            <el-table-column style="color:red"
                    v-if="showRemark"
                    prop="datenumber"
                    sortable
                    label="未跟进天数"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="name1"
                    sortable
                    label="客户名称"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="kfdm"
                    sortable
                    label="客户代码"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="contacts"
                    sortable
                    label="客户对接人"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="type"
                    sortable
                    label="跟进类别"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="mode"
                    sortable
                    label="跟进方式"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="kfmyd"
                    sortable
                    label="客户满意度"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="name"
                    sortable
                    label="跟进人"
                    width="120">
            </el-table-column>
            <el-table-column
                    prop="nexttime"
                    sortable
                    label="下次跟进"
                    width="150">
            </el-table-column>
            <el-table-column
                    prop="xianqing"
                    label="跟进详情"
                    >
            </el-table-column>
        </el-table>
        <div class="block">
            <el-pagination
                    @size-change="handleSizeChange1"
                    @current-change="handleCurrentChange1"
                    :current-page="currentPage1"
                    :page-sizes="[10, 20, 50, 100]"
                    :page-size="20"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="400"
            ></el-pagination>
        </div>

        <genjin-info v-bind:dialogshow="dialogGenjinInfo" @dialog_close="change_customer_dialog_close"></genjin-info>
        <send-message v-bind:dialogshow="dialogSendMessage" @dialog_close="send_message_dialog_close"></send-message>
        <send-weixin v-bind:dialogshow="dialogWeixin" @dialog_close="send_weixin_dialog_close"></send-weixin>
        <send-email v-bind:dialogshow="dialogEmail" @dialog_close="send_email_dialog_close"></send-email>
    </div>
</template>

<style  scoped>


    .col-md-12 {
        display: block;
        overflow: hidden;
        background-color: #f5f5f5;
    }

    .tableHeader th {
        background-color: #f5f5f5 !important;
        /*color: #000000;*/
        /*border-color: #c5c5c5;*/
    }

    .el-tabs__content {
        padding: 0px !important;
    }

    .ml-10 {
        margin-left: 10px;
    }

    .mg-10 {
        margin: 10px;
    }

    .mr-10 {
        margin-right: 10px;
    }

    #customerDialog .el-dialog__body .el-form-item {
        width: 45%;
        float: left;
        margin-bottom: 5px;
    }

    #customerDialog .el-dialog__body .el-form-item:nth-child(odd) {
        float: right;
    }

    #customerDialog .el-dialog__footer {
        clear: both;
    }

    .tableRow {
        cursor: pointer;
    }
</style>

<script>
  module.exports = {
    methods: {
      handleSizeChange1 (val) {
        console.log(`每页 ${val} 条`)
      },
      handleCurrentChange1 (val) {
        console.log(`当前页: ${val}`)
      },
      handleClick (row) {
        console.log(row)
      },
      handleSelectionChange (val) {
        //显示弹框
        console.log(333)
        this.dialogCostoms = true
      },

      openChangeCustomerDialog (val) {
        this.dialogCostomsChange = true
      },

      handleDelCustomer(val){
        // 删除操作
        this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消操作'
          });
        });

      },

      handleImport(val){
        if (val === 1) {
          //导入操作
          this.$alert('打开文件夹导入工作', '导入', {
            confirmButtonText: '确定',
            callback: action => {
              this.$message({
                type: 'success',
                message: '导入成功'
              });
            }
          });
        }else{
          //导出操作
          this.$alert('打开文件夹导出工作', '导出', {
            confirmButtonText: '确定',
            callback: action => {
              this.$message({
                type: 'success',
                message: '导出表格成功'
              });
            }
          });
        }
      },

      handleButtons(val){
        switch(val){
          case 1:
            this.dialogSendMessage = 'true'
            console.log(this.dialogSendMessage)
            break;
          case 2:
            this.dialogWeixin = 'true'
            console.log(this.dialogWeixin)
            break;
          case 3:
            this.dialogEmail = 'true'
            console.log(this.dialogEmail)
            break;
          case 4:
            this.dialogGenjinInfo = 'true'
            console.log(this.dialogGenjinInfo)
            break;
          case 6:
            this.$confirm('是否继续操作?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
              this.$message({
                type: 'success',
                message: '操作成功!'
              })
            }).catch(() => {
              this.$message({
                type: 'info',
                message: '已取消'
              })
            })
            break;
        }

      },
      handleChangeCustomer(val){
        this.dialogGenjinInfo = 'true'
        console.log(this.dialogGenjinInfo)
      },
      dialogAdd () {
        this.$confirm('是否继续操作?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$message({
            type: 'success',
            message: '操作成功!'
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          })
        })
      },
      getSummaries (param) {
        const { columns, data } = param
        const sums = []
        columns.forEach((column, index) => {
          if (index === 0) {
            sums[index] = '总价'
            return
          }
          const values = data.map(item => Number(item[column.property]))
          if (!values.every(value => isNaN(value))) {
            sums[index] = values.reduce((prev, curr) => {
              const value = Number(curr)
              if (!isNaN(value)) {
                return prev + curr
              } else {
                return prev
              }
            }, 0)
            sums[index] += ' 元'
          } else {
            sums[index] = ''
          }
        })

        return sums
      },
      showHide (text) {
        console.log(text)
      },
      send_message_dialog_close(val){
        console.log(val)
        this.dialogSendMessage = false
      },
      send_weixin_dialog_close(val){
        this.dialogWeixin = false
      },
      send_email_dialog_close(val){
        this.dialogEmail = false
      },
      change_customer_dialog_close(val){
        console.log(val)
        this.dialogGenjinInfo = false
      },
      clickfullscreen () {
        this.fullscreen = !this.fullscreen
      },
    },

    data () {
      return {
              inputSearch: "",
      selectsearch: "",
        currentPage1: 10,
        dialogCostoms: false,
        dialogCostomsChange: false,
        dialogSendMessage:false,
        dialogWeixin:false,
        dialogEmail:false,
        dialogGenjinInfo:false,     //客户跟进
        customer: {
          name: '',
          customercode: '',
          customerstatus: '',
          customercate: '',
          creditrank: '',
          creditline: '',
          capital: '',
          annualsales: '',
          bank: '',
          certificateno: '',
          address: '',
          area: '',
          brand: '',
          bankaccount: '',
          trademark: '',
          website: '',
          lperson: '',
          lphone: '',
          contacts: '',

          phone: '',
          phonenum: '',
          weixin: '',
          email: '',
          fax: '',
          resource: '',
          requirement: '',
          ordercountmonth: '',
          purchaseamountmonth: '',
          ordercountyear: '',
          purchaseamountyear: '',
          customerstaffname: '',
          customerstaffcode: '',
          operator: '',
          insertime: '',
          remark: '',
        },

        form: {
          typeId: ''
        },

        select: {
          name: '',
          introduce: '',
          cooperative_brand: '',
          customer_status: '',
          customer_type: '',
          customer_level: '',
          now_principal_id: '',
          last_follow_up_date: '',
          create_date: '',
        },

        crmsclientType: [
          { typename: '老客户' },
          { typename: '意向客户' },
        ],

        crmsclientStatic: [
          { typename: '业务拓展' },
          { typename: '订单跟进' },
          { typename: '料/款跟进' },
        ],

        crmsclientRank: [
          { typename: 'A类' },
          { typename: 'B类' },
          { typename: 'C类' },
          { typename: 'D类' },
        ],

        customerstaffs: [
          { typename: '客服1' },
          { typename: '客服2' },
          { typename: '客服3' },
          { typename: '客服4' },
        ],

        changeReason: [
          { typename: '交接原因一' },
          { typename: '交接原因二' },
          { typename: '交接原因三' },
          { typename: '其他' },
        ],

        options1: [],

        pickerOptions2: {
          shortcuts: [{
            text: '最近一周',
            onClick (picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
              picker.$emit('pick', [start, end])
            }
          }, {
            text: '最近一个月',
            onClick (picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
              picker.$emit('pick', [start, end])
            }
          }, {
            text: '最近三个月',
            onClick (picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
              picker.$emit('pick', [start, end])
            }
          }]
        },  //日期控件
        pickerOptions1: {
          disabledDate (time) {
            return time.getTime() > Date.now()
          },
          shortcuts: [{
            text: '今天',
            onClick (picker) {
              picker.$emit('pick', new Date())
            }
          }, {
            text: '昨天',
            onClick (picker) {
              const date = new Date()
              date.setTime(date.getTime() - 3600 * 1000 * 24)
              picker.$emit('pick', date)
            }
          }, {
            text: '一周前',
            onClick (picker) {
              const date = new Date()
              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
              picker.$emit('pick', date)
            }
          }]
        }, //首次合作日期

        showCustomerCode: true,
        showCustomerStatus: true,
        showCustomerCate: true,
        showCreditRank: true,
        showCreditLine: true,
        showCapital: true,
        showAnnualSales: true,
        showBank: true,
        showCertificateNo: true,
        showAddress: true,
        showArea: true,
        showBrand: true,
        showBankAccount: true,
        showTrademark: true,
        showWebsite: true,
        showLperson: true,
        showLphone: true,
        showContacts: true,

        showPhone: true,
        showPhoneNum: true,
        showWeixin: true,
        showEmail: true,
        showFax: true,
        showResource: true,
        showRequirement: true,
        showOrderCountMonth: true,
        showPurchaseAmountMonth: true,
        showOrderCountYear: true,
        showPurchaseAmountYear: true,
        showCustomerStaffName: true,
        showCustomerStaffCode: true,
        showOperator: true,
        showInsertime: true,
        showRemark: true,


        tableData: [{
          date: '2016-05-02 08:59',
          id:'1',
          datenumber:'3天',
          nexttime:'2016-05-02 08:59',
          name1: '某某大珠宝公司',
          kfdm:'DGFH',
					name: '客服1',
					contacts: '联系人1',
					type: '开发跟进',
					mode: '微信',
					kfmyd:'非常好',
					xianqing: '上海市普陀区金沙江路 1518 弄上海市普陀区金沙江路 1518 弄上海市普陀区金沙江路 1518 弄上海市普陀区金沙江路 1518 弄上海市普陀区金沙江路 1518 弄'
          
        }, {
          date: '2016-05-04 08:59',
          id:'2',
          datenumber:'20天',
          nexttime:'2016-05-02 08:59',
          name1: '某某大珠宝公司',
          kfdm:'DGFH',
					name: '欧阳某某',
					contacts: '联系人2',
					type: '签单跟进',
					mode: '电话',
					kfmyd:'良好',
          xianqing: '上海市普陀区金沙江路 1517 弄上海市普陀区金沙江路 1518 弄上海市普陀区金沙江路 1518 弄上海市普陀区金沙江路 1518 弄'
				},{
          date: '2018-05-04 23:00',
          id:'3',
          datenumber:'60天',
          nexttime:'2016-05-02 08:59',
          name1: '某某大珠宝公司',
          kfdm:'DGFH',
					name: '客服4',
					contacts: '法人',
					type: '生产跟进',
					mode: '邮件',
					kfmyd:'待进一步',
					xianqing: '上海市普陀区金沙江路 1517 弄上海市普陀区金沙江路 1518 弄上海市普陀区金沙江路 1518 弄上海市普陀区金沙江路 1518 弄'
				},{
					date: '2018-05-04 23:00',
					name: '客服4',
					type: '生产跟进',
					mode: '短信',
					kfmyd:'不太满意',
					xianqing: '上海市普陀区金沙江路 1517 弄上海市普陀区金沙江路 1518 弄上海市普陀区金沙江路 1518 弄上海市普陀区金沙江路 1518 弄'
				},{
					date: '2018-05-04 23:00',
					name: '客服4',
					type: '生产跟进',
					mode: '面谈',
					kfmyd:'不满意',
					xianqing: '上海市普陀区金沙江路 1517 弄上海市普陀区金沙江路 1518 弄上海市普陀区金沙江路 1518 弄上海市普陀区金沙江路 1518 弄'
				},{
					date: '2018-05-04 23:00',
					name: '客服4',
					contacts: '王某某某',
					type: '生产跟进',
					mode: 'QQ',
					xianqing: '上海市普陀区金沙江路 1517 弄上海市普陀区金沙江路 1518 弄上海市普陀区金沙江路 1518 弄上海市普陀区金沙江路 1518 弄'
				},{
					date: '2018-05-04 23:00',
					name: '客服4',
					type: '生产跟进',
					mode: '面谈',
					xianqing: '上海市普陀区金沙江路 1517 弄上海市普陀区金沙江路 1518 弄上海市普陀区金沙江路 1518 弄上海市普陀区金沙江路 1518 弄'
				},{
					date: '2018-05-04 23:00',
					name: '客服4',
					type: '生产跟进',
					mode: '面谈',
					xianqing: '上海市普陀区金沙江路 1517 弄上海市普陀区金沙江路 1518 弄上海市普陀区金沙江路 1518 弄上海市普陀区金沙江路 1518 弄'
				},{
					date: '2018-05-04 23:00',
					name: '客服4',
					type: '生产跟进',
					mode: 'QQ',
					xianqing: '上海市普陀区金沙江路 1517 弄上海市普陀区金沙江路 1518 弄上海市普陀区金沙江路 1518 弄上海市普陀区金沙江路 1518 弄'
				},
				]
        ,
        multipleSelection: [],
        fullscreen: false,
      }
    },
    components: {
      // 将组建加入组建库
      'send-message': 'url:./send/send-message.vue',
      'send-weixin': 'url:./send/send-weixin.vue',
      'send-email': 'url:./send/send-email.vue',
      'genjin-info': 'url:./dialog/genjin-info.vue',
      'dialog-tools': 'url:./tools/dialog-tools.vue',
    },
  }
</script>
